import SwiftUI

struct AnimatableProperties_Rotation : View {
    @State var angle: Double = 0.0
    
    var body: some View {
        VStack(spacing: 30) {
            Text("Animatable Properties")
                .font(.largeTitle)
            
            Text("Rotation")
                .font(.title)
            
            Text(".....")
            
            makeDemoView()
            
            Spacer()
            
            Button(action: {
                angle += 20.0
            }, label: {
                Text("Rotate clockwise")
                    .font(.title)
                    .padding(.bottom, 50)
            })
        }
    }
    
    func makeDemoView() -> some View {
        ZStack {
            RoundedRectangle(cornerRadius: 16)
                .foregroundColor(.orange)
                .frame(width: 300, height: 150)
            
            // 箭头
            Image(systemName: "arrow.right")
                .font(.title)
                .foregroundColor(.black)
        }
        .rotationEffect(Angle(degrees: angle)) // 正角度表示顺时针转动
        .animation(.easeInOut, value: angle)
    }
}
